﻿using Shop.RemoteModel.SpecTemplate.Model;
using Shop.StoreGatewayModular.Interface;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    [ApiRouteName("/shop/spec/template/{name}")]
    internal class SpecTemplateApi : ApiController
    {
        private readonly ISpecTemplateService _Service;

        public SpecTemplateApi (ISpecTemplateService service)
        {
            this._Service = service;
        }
        /// <summary>
        /// 设置分类的排序位
        /// </summary>
        /// <param name="param"></param>
        public Dictionary<long, int> SetSort (LongParam<int> param)
        {
            return this._Service.SetSort(param.Id, param.Value);
        }
        public long Add (SpecTemplateAdd datum)
        {
            return this._Service.Add(datum);
        }

        public void Delete ([NumValidate("shop.spec.template.id.error", 1)] long id)
        {
            this._Service.Delete(id);
        }

        public SpecTemplateDto Get ([NumValidate("shop.spec.template.id.error", 1)] long id)
        {
            return this._Service.Get(id);
        }

        public SpecTemplateItem[] GetItems ([NumValidate("shop.group.spec.id.error", 1)] LongNullParam<string> query)
        {
            return this._Service.GetItems(query.Id, query.Value);
        }

        public SpecTemplateDto[] Gets ([NumValidate("shop.spec.template.id.error", 1)] long templateId)
        {
            return this._Service.Gets(templateId);
        }

        public bool Set (LongParam<SpecTemplateSet> set)
        {
            return this._Service.Set(set.Id, set.Value);
        }

        public void SetIsEnable (LongParam<bool> set)
        {
            this._Service.SetIsEnable(set.Id, set.Value);
        }
    }
}
